<template>
  <el-select
    :clearable="clearable"
    v-bind="$attrs" v-model="$__value" v-on="$listeners">
    <el-option
      :key="item[valAttrName]"
      :label="item[labelAttrName]"
      :value="item[valAttrName]"
      v-for="item in options">
    </el-option>
  </el-select>
</template>

<script>

  export default {
    name: 'ASelect',
    props: {
      clearable: {
        type: Boolean,
        default: true
      },
      value: {
        type: [Number, String],
        require: true
      },
      options: {
        type: Array,
        require: true
      },
      labelAttrName: {
        type: String,
        default: 'label'
      },
      valAttrName: {
        type: String,
        default: 'value'
      }
    },
    computed: {
      $__value: {
        get() {
          return this.value
        },
        set(val) {
          this.$emit('update:value', val)
        }
      }
    },

    methods: {}
  }
</script>

<style lang="scss" scoped>

</style>
